#ifndef AGENT_H
#define AGENT_H

#include <QObject>
#include <QRandomGenerator>
#include <QVector>

class Maze;

class Agent
{
public:
    Agent( const Maze& m, double learningrate = 0.1, double discountfactor = 0.9, double explorationrate = 0.1 );
    void updateQValue( int currx, int curry, int action, int nextx, int nexty, double reward );
    int  chooseAction( int x, int y );
    void move( int action );
    int  getX() const;
    int  getY() const;
    void decayExplorationRate( double decayRate );

private:
    const Maze&                       maze;
    QVector<QVector<QVector<double>>> qTable;
    double                            learningRate;     // 学习效率
    double                            discountFactor;   // 衰减值
    double                            explorationRate;  // 探索率
    int                               x;
    int                               y;
};

#endif  // AGENT_H
